package com.jellyfishumbrella.GL;

import java.util.ArrayList;

import org.newdawn.slick.opengl.Texture;

public class Surface implements Cloneable {
	public String name;
	public Material material;
	public Shaders shaders;
	public boolean useShaders;
	public ArrayList<Texture> textures;

	public Surface(String name) {
		this.name = name;
		material = new Material();
		shaders = null;
		useShaders = false;
		textures = new ArrayList<Texture>();
	}

	public void setupMaterial(Material mat, String[] shaderFiles) {
		material = mat;
		String vert = shaderFiles[0];
		String frag = shaderFiles[1];
		shaders = new Shaders(vert, frag);
		useShaders = shaders.useShader;
	}

	public void clear() {
		textures = new ArrayList<Texture>();
	}

	public Surface clone() {
		Surface newSurface = new Surface(name);
		newSurface.material = material;
		newSurface.shaders = shaders;
		newSurface.useShaders = useShaders;
		newSurface.textures = textures;
		return newSurface;
	}
	
	public String toString(){
		return name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Surface other = (Surface) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
